import React, { useEffect } from "react";
import { useNavigate } from "react-router-dom";
import { Button } from "react-vant";
import Header from "../../components/Header";
import { LeftOutline } from "antd-mobile-icons";
function My() {
  const userInfo = JSON.parse(localStorage.getItem("userInfo"));
  console.log(userInfo);
  const navigate=useNavigate()

  useEffect(()=>{
    let token = localStorage.getItem('token')
    if(!token){
       navigate('/login')
    }
  },[])
  return (
    <div>
        {/* 头部组件 */}
      <Header left={<LeftOutline />} title="我的"></Header>
      <img src={userInfo.avatar} alt=""  style={{width:'100px',height:'100px'}}/>
      <h2>{userInfo.nickname}</h2>

      <Button onClick={()=>navigate('/collect')}>我的收藏</Button>
    </div>
  );
}

export default My;
